02. Matrix Addition

Matrix Addition

To add one matrix to the other we need to:

  • Verify that the matrices are of the same dimensions
  • Make sure we add elements in the correct corresponding index.

To put this into context, let's look at an example:

We will focus on the random matrix we saw in equation 11:

A=[a11a12a13..a1na21a22a23..a2na31a32a33..a3n:am1am2am3amn]A=\begin{bmatrix} a_{11} &a_{12} &a_{13}&..& a_{1n}\\ a_{21} &a_{22} &a_{23}&..& a_{2n}\\a_{31} &a_{32} &a_{33}&..& a_{3n}\\ :\\a_{m1} &a_{m2} &a_{m3}&……& a_{mn}\end{bmatrix}

The dimensions of matrix AA are mmxnn.
This means that the matrix has mm rows and nn columns.

Matrix AA can only be added to another matrix with mm rows and nn columns. For example, matrix BB.

B=[b11b12b13..b1nb21b22b23..b2nb31b32b33..b3n:bm1bm2bm3bmn]B=\begin{bmatrix} b_{11} &b_{12} &b_{13}&..& b_{1n}\\ b_{21} &b_{22} &b_{23}&..& b_{2n}\\b_{31} &b_{32} &b_{33}&..& b_{3n}\\ :\\b_{m1} &b_{m2} &b_{m3}&……& b_{mn}\end{bmatrix}

Equation 12

As long as the dimensions match, the addition is very simple:

Simply add element aija_{ij} in AA to the corresponding element bijb_{ij} in BB.

A+B=[a11a12a13..a1na21a22a23..a2na31a32a33..a3n:am1am2am3amn]+[b11b12b13..b1nb21b22b23..b2nb31b32b33..b3n:bm1bm2bm3bmn]A+B=\begin{bmatrix} a_{11} &a_{12} &a_{13}&..& a_{1n}\\ a_{21} &a_{22} &a_{23}&..& a_{2n}\\a_{31} &a_{32} &a_{33}&..& a_{3n}\\ :\\a_{m1} &a_{m2} &a_{m3}&……& a_{mn}\end{bmatrix}+\begin{bmatrix} b_{11} &b_{12} &b_{13}&..& b_{1n}\\ b_{21} &b_{22} &b_{23}&..& b_{2n}\\b_{31} &b_{32} &b_{33}&..& b_{3n}\\ :\\b_{m1} &b_{m2} &b_{m3}&……& b_{mn}\end{bmatrix}

A+B=[a11+b11a12+b12a13+b13..a1n+b1na21+b21a22+b22a23+b23..a2n+b2na31+b31a32+b32a33+b33..a3n+b3n:am1+bm1am2+bm2am3+bm3amn+bmn]A+B=\begin{bmatrix} a_{11}+ b_{11} &a_{12}+ b_{12} &a_{13}+ b_{13}&..& a_{1n}+ b_{1n}\\ a_{21}+ b_{21} &a_{22} + b_{22}&a_{23}+ b_{23}&..& a_{2n}+ b_{2n}\\a_{31}+ b_{31} &a_{32}+ b_{32} &a_{33}+ b_{33}&..& a_{3n}+ b_{3n}\\ :\\a_{m1}+ b_{m1} &a_{m2}+ b_{m2} &a_{m3}+ b_{m3}&……& a_{mn}+ b_{mn}\end{bmatrix}

Equation 12